/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package guiExtentions;

import autoUpdate.UpdateManager;
import com.google.gdata.data.photos.AlbumEntry;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import javax.swing.DefaultListCellRenderer;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.ListCellRenderer;

/**
 *
 * @author paskud
 */
public class WebAlbumRenderer implements ListCellRenderer {
  protected DefaultListCellRenderer defaultRenderer = new DefaultListCellRenderer();

  @Override
  public Component getListCellRendererComponent(JList list, Object value, int index,
      boolean isSelected, boolean cellHasFocus) {
    String text = null;
    Color bgColor = Color.WHITE;

    JLabel renderer = (JLabel) defaultRenderer.getListCellRendererComponent(list, value, index,
        isSelected, cellHasFocus);

    if (value instanceof AlbumEntry) {
      AlbumEntry album = (AlbumEntry) value;
      text = album.getTitle().getPlainText();
      
      if (UpdateManager.IsWatched(album.getId()))
        bgColor = Color.GREEN;
      else
          bgColor = Color.WHITE;
    } else {
      text = value.toString();
    }

    renderer.setText(text);
    renderer.setBackground(bgColor);
    renderer.setForeground(Color.black);
    return renderer;
  }
}
